package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Person struct {
	Name string `form:"name"`
}

//get
func bindget(c *gin.Context) {
	var p Person
	if c.ShouldBindQuery(&p) == nil {
		//log.Panicln(p.Name)
		c.JSON(http.StatusOK, gin.H{
			"data": p,
		})
	}
}

//post
func bindpost(c *gin.Context) {
	var p Person
	if c.ShouldBind(&p) == nil {
		//log.Panicln(p.Name)
		c.JSON(http.StatusOK, gin.H{
			"data": p,
		})
	}
}

func main() {
	r := gin.Default()

	r.Any("/perg", bindget)
	r.Any("/perp", bindpost)
	r.Run(":8080")
}
